package com.zqxq.lottery.entity.o2o.product;

import com.zqxq.lottery.entity.po.product.ProductPO;
import com.zqxq.lottery.entity.po.user.UserProductPO;
import com.zqxq.lottery.entity.vo.product.ProductVO;
import com.zqxq.lottery.entity.vo.user.UserProductVO;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;

public class UserProductO2O {

    public static UserProductPO toPO(UserProductVO vo) {
        if (vo == null) {
            return null;
        }
        UserProductPO userProductPO = new UserProductPO();
        if(!StringUtils.isEmpty(vo.getId()) && vo.getId()!=""){
            userProductPO.setId(Long.valueOf(vo.getId()));
        }
        userProductPO.setUser_id(Long.valueOf(vo.getUserId()));
        userProductPO.setProduct_id(Long.valueOf(vo.getProductId()));
        userProductPO.setNum(Integer.valueOf(vo.getNum()));
        if(vo.getExchangeMethod()!=null && vo.getExchangeMethod()!=""){
            userProductPO.setExchange_method(Integer.valueOf(vo.getExchangeMethod()));
        }
        userProductPO.setType(Integer.valueOf(vo.getType()));
        return userProductPO;
    }
}
